import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    // 重定向
    redirect:'/layout'
  },
  {
    // layout页面
    name:'layout', 
    path:'/layout',
    // 重定向到二级路由home上
    redirect:'/layout/home',
    component:()=>import('@/views/layout'),
    children: [
      {
        // 首页
        name:'home',
        path:'home',
        component:()=>import('@/views/home'),
        meta: { // 元信息 给当前路由对象绑定值
          title:'首页'
        }
      },
      {
        // 搜索页
        name:'search',
        path:'search',
        component:()=>import('@/views/search'),
        meta:{
          title:'搜索'
        }
      }
    ]
  },
  
]

const router = new VueRouter({
  routes
})

export default router
